<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<script>
    $(".num").html("${page.totalCount}条评论");
</script>
<c:choose>
    <c:when test="${page.currentPage > 1}"><script>$("#hotComment").hide();</script></c:when>
    <c:otherwise><script>$("#hotComment").show();</script></c:otherwise>
</c:choose>
<!--最新评论-->
    <h4>
        最新评论
        <span class="newNum">${page.totalCount}条评论</span>
    </h4>
    <div id="list">
        <c:forEach items="${newestCommentList}" var="n" varStatus="st">
           <div class="box <c:if test="${st.last}">boxLast</c:if>">
                        <!--头像-->
                        <div class="picBox">
                            <a href="javascript:void(0);">
                                <c:choose>
                                    <c:when test="${n.uPic != null and n.uPic != ''}">
                                        <img class="head" src="${n.uPic}">
                                    </c:when>
                                    <c:otherwise>
                                        <img class="head" src="../image/user_img.jpg">
                                    </c:otherwise>
                                </c:choose>
                            </a>
                        </div>
                        <!--名字 内容-->
                        <div class="contentComment">
                            <!--内容-->
                            <div class="main">
                                <div class="replyBox">
                                    <!--名字-->
                                    <span class="user">
                                <c:choose>
                                    <c:when test="${n.uName != null and n.uName != ''}">
                                        <a href="javascript:void(0);">${n.uName}</a>
                                    </c:when>
                                    <c:otherwise>
                                        <a href="javascript:void(0);">阁下暂没留下大名</a>
                                    </c:otherwise>
                                </c:choose>
                            </span>
                                    <!--内容-->
                                    <span class="replyCon">
                                            ${n.msg}
                                    </span>
                                    <span class="commentReport">举报</span>
                                    <div class="commentShareBox">分享</div>
                                </div>
                            </div>
                            <c:if test="${n.reply != null and n.reply != ''}">
                                <%--回复的原评论--%>
                                <div class="commentBox">
                                    <p class="commentCon">
                                        <span class="userComment">
                                             <c:choose>
                                                 <c:when test="${n.reply.uName != null and n.reply.uName != ''}">
                                                     <a href="javascript:void(0);">${n.reply.uName}：</a>
                                                 </c:when>
                                                 <c:otherwise>
                                                     <a href="javascript:void(0);">阁下暂没留下大名：</a>
                                                 </c:otherwise>
                                             </c:choose>
                                        </span>
                                            ${n.reply.msg}
                                    </p>
                                </div>
                            </c:if>
                            <div class="info_">
                                <a class="reply" href="javascript:void(0);" onclick="appendMsgCon(this,'${n.cId}','${n.uId}','${n.uName}');">回复</a>
                                <c:set var="isZan" value="0"></c:set>
                                <c:forEach items="${voteLogs}" var="v">
                                    <c:if test="${v.uId == user.uId and v.cId == n.cId and v.status == 0}">
                                        <c:set var="isZan" value="1"></c:set>
                                    </c:if>
                                </c:forEach>
                                <a class="praise <c:if test="${isZan == '1'}">praised</c:if>" href="javascript:void(0);" onclick="clickZan(this,'${n.cId}','${user.uId}');">${n.likeNum}</a>
                                <c:if test="${n.uId == user.uId}">
                                    <span class="delLine"></span>
                                    <a class="delete" href="javascript:void(0);" onclick="deleteComment(this,'${n.cId}');">删除</a>
                                </c:if>
                                <p class="time">
                                    <fmt:formatDate value="${n.createTime}" pattern="yyyy-MM-dd hh:mm:ss"></fmt:formatDate>
                                </p>
                            </div>
                        </div>
                    </div>
        </c:forEach>
    </div>
    <!--分页按钮-->
<c:if test="${page != null}">
    <div class="pageComment">
        <!--上一页按钮-->
        <a id="prePage" href="javascript:void(0);" onclick="getNewetsComment(${page.currentPage - 1})">
            <img src="../image/prev.png">
        </a>
        <!--具体页数按钮-->
        <c:choose>
            <c:when test="${page.totalPage <= 5}">
                <c:forEach begin="1" end="${page.totalPage}" varStatus="st">
                    <a href="javascript:void(0);" <c:if test="${st.index == page.currentPage}">class="current"</c:if>
                       onclick="getNewetsComment(${st.index})">${st.index}</a>
                </c:forEach>
            </c:when>
            <c:otherwise>
                <c:choose>
                    <c:when test="${page.currentPage == commentEnd}">
                        <c:set var="commentBegin" value="${page.currentPage}" scope="session"></c:set>
                        <c:choose>
                            <c:when test="${musicEnd == page.totalPage}">
                                <c:set var="commentEnd" value="${page.totalPage}" scope="session"></c:set>
                            </c:when>
                            <c:otherwise>
                                <c:set var="commentEnd" value="${commentEnd + 4}" scope="session"></c:set>
                            </c:otherwise>
                        </c:choose>
                        <c:forEach begin="${commentBegin}" end="${commentEnd}" varStatus="st">
                            <a href="javascript:void(0);" <c:if test="${st.index == page.currentPage}">class="current"</c:if>
                               onclick="getNewetsComment(${st.index})">${st.index}</a>
                        </c:forEach>
                    </c:when>
                    <c:otherwise>
                        <c:forEach begin="${commentBegin}" end="${commentEnd}" varStatus="st">
                            <a href="javascript:void(0);" <c:if test="${st.index == page.currentPage}">class="current"</c:if>
                               onclick="getNewetsComment(${st.index})">${st.index}</a>
                        </c:forEach>
                    </c:otherwise>
                </c:choose>
                <span class="point">...</span>
                <a href="javascript:void(0);" <c:if test="${page.totalPage == page.currentPage}">class="current"</c:if>
                   onclick="getNewetsComment(${page.totalPage})">${page.totalPage}</a>
            </c:otherwise>
        </c:choose>
        <!--下一页按钮-->
        <a id="nextPage" href="javascript:void(0);" onclick="getNewetsComment(${page.currentPage + 1})">
            <img src="../image/next.png">
        </a>
    </div>
</c:if>


